<?php
	// 这是中文
	include_once ('inc/conn.php');
	include_once ('inc/function.php');

	$page = "index";

	load_pages($page);
	
	function load_pages($page) {
		$output = file_get_contents("./interface/{$page}.html");
		// $output = str_replace("###CATEGORIESLIST###", get_categories(), $output);
		
		echo $output;
	}

	function get_categories() {
		$output = "";
		$result = get_url_data($_SERVER['SERVER_NAME'] . "/inc/api/database//v1/get_categories");

		if ($result) {
			$result = json_decode($result, true);

			$output .= '<ul class="nav-dropdown-items">';

			foreach ($result['lists'] as $list) {
				$temp_list =
					'<li class="nav-item">
						<a id="%s" href="#" class="nav-link">
							<i class="icon icon-target"></i> %s
						</a>
					</li>';

				$output .= sprintf($temp_list, $list['category'], $list['category']);
			}

			$output .= '</ul>';
		}

		return $output;
	}
?>
